USE [TrioJFLApp]
GO

/****** Object:  StoredProcedure [dbo].[SP_Upload_SAPMaterialToMonitor_GC_PCN_NO]    Script Date: 09/26/2018 15:36:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


ALTER  PROCEDURE [dbo].[SP_Upload_SAPMaterialToMonitor_GC_PCN_NO] 
  @MaterialNumber NVARCHAR(20),
  @CreateUser NVARCHAR(20),
  @PCN_NO NVARCHAR(200)
  
AS 
BEGIN

SET @MaterialNumber=upper(RTRIM(@MaterialNumber))
 
	BEGIN
		UPDATE sim SET 
	    sim.PCN_NO=CASE @PCN_NO WHEN '' THEN sim.ProductHierarchy ELSE @PCN_NO END,
	    sim.GC_PCN_User=@CreateUser,
	    sim.GC_PCN_Date=GETDATE()  
	    FROM SAP_ItemMaster sim WHERE sim.Material_Number=@MaterialNumber
	END
  
END

GO


